﻿@model RMS.Models.Company

@{
    ViewBag.Title = "Overview";
}
@{
    ViewBag.Title = "Overview";
    int year = DateTime.Now.Year; 
    string src1 = "/Company/OccurenceChart?year=" + year.ToString() +"&companyId=" + Model.Id.ToString();
    string src2 = "/Company/OccurenceChart?year=" + (year - 1).ToString() + "&companyId=" + Model.Id.ToString();
    string src3 = "/Company/OccurenceChart?year=" + (year - 2).ToString() + "&companyId=" + Model.Id.ToString();

    string src4 = "/Company/CostChart?year=" + year.ToString() + "&companyId=" + Model.Id.ToString();
    string src5 = "/Company/CostChart?year=" + (year - 1).ToString() + "&companyId=" + Model.Id.ToString();
    string src6 = "/Company/CostChart?year=" + (year - 2).ToString() + "&companyId=" + Model.Id.ToString();
}

<h2>Problems Overview</h2>
<table>
<tr>
    <th colspan="4">Current Year Problem Cost Limit</th>
</tr>
<tr>
    <th>Problem's Group</th>
    <th>Limit</th>
    <th>Current Year</th>
    <th>Status</th>
</tr>
@foreach (var limit in Model.CompanyProblemLimits)
{
    <tr>
        <td>@limit.ProblemGroup.Name</td>
        <td>@limit.Limit.ToString("n2")</td>
        <td>@limit.Company.CompaniesProblems.Sum(x => x.Problem.Occurrences.Where(y=>(y.User.CompanyId == x.CompanyId)&&(y.Date.Year == DateTime.Now.Year)&&(y.Problem.ProblemGroupId == limit.ProblemGroupId)).Sum(y => y.Cost)).ToString("n2")</td>
        <td>
            @if (limit.Limit >= @limit.Company.CompaniesProblems.Sum(x => x.Problem.Occurrences.Where(y => (y.User.CompanyId == x.CompanyId) && (y.Date.Year == DateTime.Now.Year) && (y.Problem.ProblemGroupId == limit.ProblemGroupId)).Sum(y => y.Cost)))
            {
                <span style="color:Green;">Normal</span>
            }
            else
            {
                <span style="color:Red;">Exceed</span>
            }
        </td>
    </tr>
}
</table>
<br />
<img src=@src1 alt="Chart Overview"/><img src=@src4 alt="Chart Overview"/><br />
<img src=@src2 alt="Chart Overview"/><img src=@src5 alt="Chart Overview"/><br />
<img src=@src3 alt="Chart Overview"/><img src=@src6 alt="Chart Overview"/><br />



<h2>Overview</h2>
